package com.zhaoqi.hr.dto.response;

import com.zhaoqi.hr.entity.EmployerProfile;
import com.zhaoqi.hr.entity.User;

import java.time.LocalDateTime;

/**
 * 用工方档案响应DTO
 */
public class EmployerProfileResponse {
    private Long id;
    private String companyName;
    private String businessLicense;
    private String legalPerson;
    private String businessAddress;
    private String businessScope;
    private String contactPhone;
    private String qualificationStatus;
    private String qualificationRemark;
    private Double depositBalance;
    private Double frozenAmount;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private UserResponse user;

    public EmployerProfileResponse() {}

    public EmployerProfileResponse(EmployerProfile profile) {
        this.id = profile.getId();
        this.companyName = profile.getCompanyName();
        this.businessLicense = profile.getBusinessLicense();
        this.legalPerson = profile.getLegalPerson();
        this.businessAddress = profile.getBusinessAddress();
        this.businessScope = profile.getBusinessScope();
        this.contactPhone = profile.getContactPhone();
        this.qualificationStatus = profile.getQualificationStatus().name();
        this.qualificationRemark = profile.getQualificationRemark();
        this.depositBalance = profile.getDepositBalance() != null ? profile.getDepositBalance().doubleValue() : null;
        this.frozenAmount = profile.getFrozenAmount() != null ? profile.getFrozenAmount().doubleValue() : null;
        this.createdAt = profile.getCreatedAt();
        this.updatedAt = profile.getUpdatedAt();
        
        // 设置用户信息
        if (profile.getUser() != null) {
            UserResponse userResponse = new UserResponse();
            userResponse.setId(profile.getUser().getId());
            userResponse.setUsername(profile.getUser().getUsername());
            userResponse.setRealName(profile.getUser().getRealName());
            userResponse.setPhone(profile.getUser().getPhone());
            userResponse.setIdCard(profile.getUser().getIdCard());
            userResponse.setAddress(profile.getUser().getAddress());
            userResponse.setRole(profile.getUser().getRole().name());
            userResponse.setStatus(profile.getUser().getStatus().name());
            userResponse.setCreatedAt(profile.getUser().getCreatedAt());
            this.user = userResponse;
        }
    }

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getBusinessLicense() {
        return businessLicense;
    }

    public void setBusinessLicense(String businessLicense) {
        this.businessLicense = businessLicense;
    }

    public String getLegalPerson() {
        return legalPerson;
    }

    public void setLegalPerson(String legalPerson) {
        this.legalPerson = legalPerson;
    }

    public String getBusinessAddress() {
        return businessAddress;
    }

    public void setBusinessAddress(String businessAddress) {
        this.businessAddress = businessAddress;
    }

    public String getBusinessScope() {
        return businessScope;
    }

    public void setBusinessScope(String businessScope) {
        this.businessScope = businessScope;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    public String getQualificationStatus() {
        return qualificationStatus;
    }

    public void setQualificationStatus(String qualificationStatus) {
        this.qualificationStatus = qualificationStatus;
    }

    public String getQualificationRemark() {
        return qualificationRemark;
    }

    public void setQualificationRemark(String qualificationRemark) {
        this.qualificationRemark = qualificationRemark;
    }

    public Double getDepositBalance() {
        return depositBalance;
    }

    public void setDepositBalance(Double depositBalance) {
        this.depositBalance = depositBalance;
    }

    public Double getFrozenAmount() {
        return frozenAmount;
    }

    public void setFrozenAmount(Double frozenAmount) {
        this.frozenAmount = frozenAmount;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public UserResponse getUser() {
        return user;
    }

    public void setUser(UserResponse user) {
        this.user = user;
    }
}
